/**
 * 
 */
package mx.com.asteca.persistencia.dao.impl;

import java.util.ArrayList;
import java.util.List;

import mx.com.asteca.persistencia.PersistenciaException;
import mx.com.asteca.persistencia.dao.ModuloDAO;
import mx.com.asteca.persistencia.entidades.Modulos;

import org.hibernate.Criteria;
import org.hibernate.criterion.Projections;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

/**
 * @author JAMARO
 * 
 */
@Repository
public class ModuloDAOImpl extends BaseDAOImpl<Modulos, Integer> implements
		ModuloDAO {

	@Override
	public List<String> getDistinctCat() throws PersistenciaException {
		try {
			Criteria criteria = getSessionFactory().getCurrentSession()
					.createCriteria(Modulos.class);
			criteria.setProjection(
					Projections.distinct(Projections.projectionList().add(
							Projections.property("columna_1"), "columna_1")))
					.setResultTransformer(
							Transformers.aliasToBean(Modulos.class));
			List<Modulos> lista = criteria.list();
			List<String> list = new ArrayList<String>();
			for(Modulos modulo : lista){
				list.add(modulo.getColumna_1());
			}
			return list;
		} catch (Exception e) {
			throw new PersistenciaException("Error en getDistinctCat: "
					+ e.getMessage(), e);
		}
	}

}
